package com.xwdeshj.controller;

import com.alibaba.fastjson.JSONObject;
import com.xwdeshj.service.XwSceincEntertainmentService;
import com.xwdeshj.utils.IMoocExceptionHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by BKWJA on 2019/1/7.
 * 景区——景区娱乐项目 控制层
 */
@Slf4j
@RequestMapping("sceEnter")
@CrossOrigin(allowCredentials = "true")
@Controller
public class XwSceincEntertainmentController extends IMoocExceptionHandler {

    @Autowired
    private XwSceincEntertainmentService xwSceincEntertainmentService;

    /**
     * 获取景区店铺 娱乐项目信息
     * @param pageindex 当前页码
     * @param pagesize 每页显示多少
     * @param starttime 开始时间
     * @param endtime 结束时间
     * @param sortfild 排序字段
     * @param sortway 排序方式
     * @param searchval 搜索值
     * @param searchkey 搜索字段
     * @param sceinc_encryptId 店铺加密id
     * @return
     */
    @RequestMapping("/getEntertainlist")
    @ResponseBody
    public JSONObject getEntertainlist(@RequestParam(value = "pageindex",defaultValue = "1")Integer pageindex,
                                         @RequestParam(value = "pagesize",defaultValue = "10") Integer pagesize,
                                         @RequestParam(value = "starttime",defaultValue = "") String starttime,
                                         @RequestParam(value = "endtime",defaultValue = "") String endtime,
                                         @RequestParam(value = "sortfild",defaultValue = "scenic_enter_createtime")
                                                 String sortfild,
                                         @RequestParam(value = "sortway",defaultValue = "desc")String sortway,
                                         @RequestParam(value = "searchval",defaultValue = "") String searchval,
                                         @RequestParam(value = "searchkey",defaultValue = "") String searchkey,
                                         String sceinc_encryptId, HttpServletRequest request){
        return xwSceincEntertainmentService.getEntertainlist(pageindex,pagesize,starttime,endtime,sortfild,sortway,
                searchval,searchkey,sceinc_encryptId,request);
    }


    /**
     *  景区——新建娱乐项目
     * @param business_encryptId 商家加密id
     * @param scenic_encryptId 店铺加密id
     * @param enterid 娱乐项目id，新建：0
     * @param enterName 娱乐项目名
     * @param enterIntr 娱乐项目简介
     * @param parmJson 娱乐项目展示图，id：娱乐项目id，imglink：图片链接
     * @param request
     * @return
     */
    @RequestMapping("/updateEntertain")
    @ResponseBody
    public JSONObject updateEntertain(String business_encryptId,String scenic_encryptId,String enterid,
                                      String enterName,String enterIntr,String parmJson,
                                      HttpServletRequest request){
        return xwSceincEntertainmentService.updateEntertain(business_encryptId,scenic_encryptId,enterid,
                enterName,enterIntr,parmJson,request);
    }

    /**
     * 根据 店铺id，娱乐项目id 获取 一条娱乐项目信息
     * @param scenic_encryptId
     * @param enterid
     * @param request
     * @return
     */
    @RequestMapping("/getEntertainOne")
    @ResponseBody
    public JSONObject getEntertainOne(String scenic_encryptId,String enterid, HttpServletRequest request){
        return xwSceincEntertainmentService.getEntertainOne(scenic_encryptId,enterid, request);
    }


    /**
     * 根据娱乐项目id，删除对应的信息
     * @param enterid  娱乐项目id
     * @param request
     * @return
     */
    @RequestMapping("/delsceinEnter")
    @ResponseBody
    public JSONObject delsceinEnter(String enterid,HttpServletRequest request){
        return xwSceincEntertainmentService.delsceinEnter(enterid,request);
    }



}
